package com.estate.web.controller.report.home;

import com.estate.common.core.domain.AjaxResult;
import com.estate.common.utils.StringUtils;
import com.estate.system.service.impl.DataEnquiriesServiceImpl;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/home/sale")
public class SaleController {

    @Resource
    private DataEnquiriesServiceImpl dataEnquiriesServiceImpl;

    /**
     * 获取近七天新增客户咨询数量
     * @param paramData key1:xDays 表示要查询最近x天的数据
     * @return sevenDaysAgoCount：最近7天数量  fourteenDaysAgoCount：上一个7天的数量 addPercentage:最近7天新增百分比
     */
//    @PreAuthorize("@ss.hasPermi('sale:getSevenDayNewEnquire')")
    @GetMapping("/getSevenDayNewEnquire")
    public AjaxResult getSevenDayNewEnquire( Map<String, Object> paramData){
        return  AjaxResult.success("success",dataEnquiriesServiceImpl.getSevenDayNewEnquire(paramData));
    }

    /**
     * 查看购买类型的咨询数量趋势
     * @param paramData
     * @return
     */
    @GetMapping("/getEnquireByEnquireType")
    public AjaxResult getEnquireByEnquireType(Map<String, Object> paramData){
        return null;
//        return  AjaxResult.success("success",dataEnquiriesServiceImpl.getEnquireByEnquireType(paramData));
    }


    /**
     * 获取近七天新增房产数量
     * @param paramData key1:xDays 表示要查询最近x天的数据
     * @return sevenDaysAgoCount：最近7天数量  fourteenDaysAgoCount：上一个7天的数量 addPercentage:最近7天新增百分比
     */
    //    @PreAuthorize("@ss.hasPermi('sale:getSevenDayNewListing')")
    @GetMapping("/getSevenDayNewListing")
    public AjaxResult getSevenDayNewListing(Map<String, Object> paramData){
        Map<String, Object> sevenDayNewListing = dataEnquiriesServiceImpl.getSevenDayNewListing(paramData);
        if(StringUtils.isNotEmpty(sevenDayNewListing)){
            return  AjaxResult.success("success",sevenDayNewListing);
        }else{
            return  AjaxResult.error("fail",null);
        }
    }
}
